<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <div id="app">
    <p>今年的年龄：{{age}}</p>
    <p>明年的年龄：{{nextAge}}</p>
  </div>
  <script src="../vue.js"></script>
  <script>
    let vm = new Vue({
      el: '#app',
      data: {
        age: 18
      },
      computed: {
        nextAge: {
          // 获取值时调用
          get() {
            console.log('get执行了！');
            return this.age + 1
          },
          // 设置值时调用（很少见）
          set() {
            console.log('set执行了！');
          }
        }
      }
    })
  </script>
</body>
</html>